package cn.wolfcode.service.impl;

import cn.wolfcode.mapper.AccountMapper;
import cn.wolfcode.service.IAccountService;
import lombok.Setter;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;

@Service
@Setter
//事务注解
@Transactional
public class AccountServiceImpl implements IAccountService {
    private AccountMapper accountMapper;


    @Override
    public void transfer(Long outId, Long inId, BigDecimal amount) {
        //事务开启
        accountMapper.subtractBalance(outId,amount);
        //事务结束  已经提交了

        //事务开启
        accountMapper.addBalance(inId,amount);
        //事务结束
    }
   /* public void getAll(){

    }
    public void listGetById(Long id){

    }*/

}
